How to Build your own Dino Den using Java
DinoGenesis via Random Eggs In the early stages of the game, most of your baby dinos will arrive in your village as Random Eggs in the Dino Den. Any dino obtained by random hatch, is called a Random Hatchling. As the name suggests, this DinoGenesis process is governed by probability. Each dino is assigned an eggCount from 0 to 500, which determines its probability in the DinoDen. In the game files, the eggCount is erroneously called the probability, but that is not really a correct designation since by Kolmogorov's Laws of Probability, the total probability can never exceed 1 (in relative form) or 100%. Example: Suppose a game offers 4 beasts (dinos) and that the eggCounts are: 1, 1, 2, 0. This gives a totalEggCount of 4. We see that the probabiltiy of getting any dino, (say the ith dino) through random egg is: Probability of Dino(i) = eggCount(i) / totalEggCount <-- Formula 1 Thus, the first and second dinos are equiprobable, each occurring one quarter of the time. The third dino is the most likely, occurring half the time. The fourth dino, has no eggs and will never occur. A dino with no random eggs is said to be Eggless. The Java Class Dino.java To build your own Dino Den in Java, you will first need a utility class to store the most important information about each dino. Please note, the code shown below, is not from the game. It is simply an adoption of common code for a Lottery in which the prizes are now dinos instead of specific cash prizes. Step 1: Build a utility class to manage the info for each dino or beast. Java Utility File: Dino.java /* The utility class Dino has constructors, accessors and mutators for dino objects. The method dinoArk() returns an ArrayList holding all the info for each of the 53 dinosaurs available as of Feb 20th, 2013. The last dino included here is the Incisivosaurus which was introduced on February 19th with the 12th wave of Bingo. Maintenance Instructions: Just add more dinos as they are released inside this method. The next dino will be the 54th. Also, update any eggCounts that have changed. Updates: Feb20th, Added INCISIVOSAURUS and dinoHurryHatch info for all dinos. */ import java.util.Random; // Import the Random class. import java.util.ArrayList; // Import the ArrayList class. public class Dino { // The instance variables. We can add more later. private String dinoName; private String dinoBiome; // "Tundra", "Forest", "Desert", "Air" private int dinoTier; // 0, 1, 2, 3 or 4. private int dinoEggCount; // Also called the probability, but is not normalized. private int dinoHurryHatch; // Initial hurry hatch cost in crystals. private int dinoHatchTime; // In hours. private int dinoCount; // Used to count dinos in experiments // * * * Accessors and Mutators * * * public String getDinoName() {return dinoName;} public void setDinoName(String newDinoName) {dinoName = newDinoName;} // public String getDinoBiome() {return dinoBiome;} public void setDinoBiome(String newDinoBiome) {dinoBiome = newDinoBiome;} // public int getDinoTier() {return dinoTier;} public void setDinoTier(int newDinoTier) {dinoTier = newDinoTier;} // public int getDinoEggCount() {return dinoEggCount;} public void setDinoEggCount(int newDinoEggCount) {dinoEggCount = newDinoEggCount;} // Used to count dinos in numerical experiments. public int getDinoCount() {return dinoCount;} public void setDinoCount(int newDinoCount) {dinoCount = newDinoCount;} public void addDino() {dinoCount++;} // * * * Constructors * * * Dino() {} // Default constructor. Dino(String newDinoName, String newDinoBiome, int newDinoTier, int newDinoEggCount, int newDinoHurryHatch) { dinoName = newDinoName; dinoBiome = newDinoBiome; dinoTier = newDinoTier; dinoEggCount = newDinoEggCount; dinoHurryHatch = newDinoHurryHatch; int dinoCount = 0; // Used to count dinos in experiments } // Full constructor. // Now build an ArrayList to hold all the dinos. public static ArrayList dinoArk() { // A method to add one copy of each dino to an ArrayList. ArrayList dinoArk = new ArrayList(); int tier0 = 0, tier1 = 1, tier2 = 2, tier3 = 3; int noEggs = 0, oneEgg = 1, fiveEggs = 5, sixEggs = 6, nineEggs = 9, fiveHundredEggs = 500; int hh7 = 7, hh8 = 8, hh10 = 10, hh12 = 12, hh13 = 13, hh17 = 17; // There are six possible hh costs. Dino Incisivosaurus = new Dino("Incisivosaurus", "Forest", tier3, noEggs, hh17); // #53 dinoArk.add( Incisivosaurus ); Dino Corgisaurus = new Dino("Corgisaurus", "Forest", tier3, noEggs, hh17); // #52 dinoArk.add( Corgisaurus ); Dino SnowPhoenix = new Dino("SnowPhoenix", "Tundra", tier3, noEggs, hh17); // #51 dinoArk.add( SnowPhoenix ); Dino Anchiornis = new Dino("SnowPhoenix", "Forest", tier2, noEggs, hh17); // #50 dinoArk.add( Anchiornis ); Dino AbominableSnowman = new Dino("AbominableSnowman", "Tundra", tier3, noEggs, hh17); // #49 dinoArk.add( AbominableSnowman ); Dino ReindeerRaptor = new Dino("ReindeerRaptor", "Tundra", tier2, noEggs, hh8); // #48 dinoArk.add( ReindeerRaptor ); Dino Penguin = new Dino("Penguin", "Tundra", tier1, noEggs, hh8); // #47 dinoArk.add( Penguin ); Dino Turkeysaurus = new Dino("Turkeysaurus", "Forest", tier2, noEggs, hh10); // #46 dinoArk.add( Turkeysaurus ); Dino Butterfly = new Dino("Butterfly", "Air", tier2, oneEgg, hh10); // #45 dinoArk.add( Butterfly ); Dino GhostMinmi = new Dino("GhostMinmi", "Desert", tier3, noEggs, hh10); // #44 dinoArk.add( GhostMinmi ); Dino GhostNemicolopterus = new Dino("GhostNemicolopterus", "Air", tier3, noEggs, hh10); // #43 dinoArk.add( GhostNemicolopterus ); Dino GhostSloth = new Dino("GhostSloth", "Tundra", tier3, noEggs, hh12); // #42 dinoArk.add( GhostSloth ); Dino GhostTurtle = new Dino("GhostTurtle", "Forest", tier2, noEggs, hh10); // #41 dinoArk.add( GhostTurtle ); Dino GhostIngridia = new Dino("GhostIngridia", "Air", tier2, noEggs, hh10); // #40 dinoArk.add( GhostIngridia ); Dino GhostTriceratops = new Dino("GhostTriceratops", "Forest", tier2, noEggs, hh12); // #39 dinoArk.add( GhostTriceratops ); Dino Skelesaurus = new Dino("Skelesaurus", "Desert", tier2, noEggs, hh10); // #38 dinoArk.add( Skelesaurus ); Dino GhostOviraptor = new Dino("GhostOviraptor", "Forest", tier1, noEggs, hh10); // #37 dinoArk.add( GhostOviraptor ); Dino GhostMesohippus = new Dino("GhostMesohippus", "Forest", tier1, noEggs, hh10); // #36 dinoArk.add( GhostMesohippus ); Dino GhostCorythosaurus = new Dino("GhostCorythosaurus", "Forest", tier2, noEggs, hh10); // #35 dinoArk.add( GhostCorythosaurus ); Dino GhostMammoth = new Dino("GhostMammoth", "Tundra", tier0, noEggs, hh12); // #34 dinoArk.add( GhostMammoth ); Dino GhostPachycephalosaurus = new Dino("GhostPachycephalosaurus", "Forest", tier3, noEggs, hh10); // #33 dinoArk.add( GhostPachycephalosaurus ); Dino Dilophosaurus = new Dino("Dilophosaurus", "Forest", tier2, oneEgg, hh10); // #32 dinoArk.add( Dilophosaurus ); Dino Phoenix = new Dino("Phoenix", "Air", tier3, oneEgg, hh10); // #31, but is it tier 4? dinoArk.add( Phoenix ); Dino Oviraptor = new Dino("Oviraptor", "Forest", tier1, oneEgg, hh10); // #30 dinoArk.add( Oviraptor ); Dino Turtle = new Dino("Turtle", "Forest", tier2, oneEgg, hh10); // #29 dinoArk.add( Turtle ); Dino Nemicolopterus = new Dino("Nemicolopterus", "Air", tier3, oneEgg, hh10); // #28 dinoArk.add( Nemicolopterus ); Dino Mesohippus = new Dino("Mesohippus", "Forest", tier1, oneEgg, hh10); // #27 dinoArk.add( Mesohippus ); Dino Minmi = new Dino("Minmi", "Desert", tier3, oneEgg, hh10); // #26 dinoArk.add( Minmi ); Dino Ingridia = new Dino("Ingridia", "Air", tier2, oneEgg, hh10); // #25 dinoArk.add( Ingridia ); Dino Sloth = new Dino("Sloth", "Tundra", tier3, sixEggs, hh12); // #24 dinoArk.add( Sloth ); Dino Corythosaurus = new Dino("Corythosaurus", "Forest", tier2, oneEgg, hh10); // #23 dinoArk.add( Corythosaurus ); Dino Spinosaurus = new Dino("Spinosaurus", "Desert", tier1, nineEggs, hh12); // #22 dinoArk.add( Spinosaurus ); Dino WoollyRhino = new Dino("WoollyRhino", "Tundra", tier2, sixEggs, hh10); // #21 dinoArk.add( WoollyRhino ); Dino Brontornis = new Dino("Brontornis", "Air", tier1, oneEgg, hh13); // #20 dinoArk.add( Brontornis ); Dino Pachycephalosaurus = new Dino("Pachycephalosaurus", "Forest", tier3, oneEgg, hh10); // #19 dinoArk.add( Pachycephalosaurus ); Dino Bambiraptor = new Dino("Bambiraptor", "Air", tier3, oneEgg, hh10); // #18 dinoArk.add( Bambiraptor ); Dino Homalocephale = new Dino("Homalocephale", "Desert", tier2, sixEggs, hh12); // #17 dinoArk.add( Homalocephale ); Dino Kentrosaurus = new Dino("Kentrosaurus", "Desert", tier2, sixEggs, hh10); // #16 dinoArk.add( Kentrosaurus ); Dino Archaeopteryx = new Dino("Archaeopteryx", "Air", tier2, oneEgg, hh10); // #15 dinoArk.add( Archaeopteryx ); Dino LuckyMammoth = new Dino("LuckyMammoth", "Tundra", tier1, noEggs, hh13); // #14 dinoArk.add( LuckyMammoth ); Dino LoveStegosaurus = new Dino("LoveStegosaurus", "Forest", tier1, noEggs, hh12); // #13 dinoArk.add( LoveStegosaurus ); Dino Andrewsarchus = new Dino("Andrewsarchus", "Tundra", tier1, nineEggs, hh8); // #12 dinoArk.add( Andrewsarchus ); Dino SabretoothTiger = new Dino("SabretoothTiger", "Tundra", tier3, oneEgg, hh10); // #11 dinoArk.add( SabretoothTiger ); Dino Raptor = new Dino("Raptor", "Desert", tier2, oneEgg, hh10); // #10 dinoArk.add( Raptor ); Dino Triceratops = new Dino("Triceratops", "Forest", tier2, sixEggs, hh12); // #9 dinoArk.add( Triceratops ); Dino Brontosaurus = new Dino("Brontosaurus", "Forest", tier1, oneEgg, hh10); // #8 dinoArk.add( Brontosaurus ); Dino Pterodactyl = new Dino("Pterodactyl", "Air", tier1, fiveEggs, hh12); // #7 Used to be 9 eggs, but changed to 5. dinoArk.add( Pterodactyl ); Dino Dimetrodon = new Dino("Dimetrodon", "Desert", tier1, nineEggs, hh10); // #6 dinoArk.add( Dimetrodon ); Dino Protoceratops = new Dino("Protoceratops", "Forest", tier1, nineEggs, hh10); // #5 dinoArk.add( Protoceratops ); // Finally we add the four common dinosaurs. Dino Mammoth = new Dino("Mammoth", "Tundra", tier0, fiveHundredEggs, hh12); // #4 dinoArk.add( Mammoth ); Dino Stegosaurus = new Dino("Stegosaurus", "Forest", tier0, fiveHundredEggs, hh12); // #3 dinoArk.add( Stegosaurus ); Dino Anklyosaurus = new Dino("Ankylosaurus", "Desert", tier0, fiveHundredEggs, hh12); // #2 dinoArk.add( Anklyosaurus ); Dino Parasaurolophus = new Dino("Parasaurolophus", "Air", tier0, fiveHundredEggs, hh12); // #1 dinoArk.add( Parasaurolophus ); return dinoArk; } // end of method dinoArk } // end of class Dino The Java Class VirtualDinoDen.java Coming soon, code that simulates how the Dino Den generates random dino eggs, created by a simple modification of well-known Lottery algorithms. It is not actual code from the game. In addition, it will enable you to explore how the Bernoulli distribution plays a role in determining how long it takes to get a particular dino. Eventually, the Java Virtual Dino Den will be available as a Java applet, that you can run in a web-page. Project 2: Build a running program to simulate the Dino Den. For educational purposes only. The Dino Den simulator allows wonderful explorations into probability and statistics. The first few steps in building the Java Virtual Dino Den, will be to process some of the raw numbers in the ArrayList generated by the method dinoArk() from the utility file given above. > > Working on this now: February 15th-19th, 2013 Step 1: Collect eggs into categories. Feb 19th, using an ArrayList of Strings to hold the dino eggs. This is the SpinningEggDrum. Step 2: The Java Virtual Dino Den is now working! Not yet posted.